using System;
using System.Data;
using Utils;
using Utils.DatabaseUtils;


namespace BDS
{
public class NeedsUI
{ 
	private int needsID;
	public int NeedsID
	{
		get { return needsID;}
		set { needsID = value;}
	}

	private String needsName;
	public String NeedsName
	{
		get { return needsName;}
		set { needsName = value;}
	}

	private String needsAlias;
	public String NeedsAlias
	{
		get { return needsAlias;}
		set { needsAlias = value;}
	}

	private int categoryPageId;
	public int CategoryPageId
	{
		get { return categoryPageId;}
		set { categoryPageId = value;}
	}

	private bool isEnable;
	public bool IsEnable
	{
		get { return isEnable;}
		set { isEnable = value;}
	}

	public NeedsUI() {}

	public NeedsUI(int needsID, String needsName, String needsAlias, int categoryPageId, bool isEnable)
	 {
		this.needsID = needsID;
 		this.needsName = needsName;
 		this.needsAlias = needsAlias;
 		this.categoryPageId = categoryPageId;
 		this.isEnable = isEnable;
 	}

	public int Add(String needsName, String needsAlias, int categoryPageId, bool isEnable)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Needs_Add",needsName,needsAlias,categoryPageId,isEnable);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Update(int needsID, String needsName, String needsAlias, int categoryPageId, bool isEnable)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Needs_Update",needsID,needsName,needsAlias,categoryPageId,isEnable);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Delete(int needsID)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Needs_Delete",needsID);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int DeleteAll()
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"Needs_DeleteAll");
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public DataSet Get(int needsID)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Needs_Get",needsID);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetAll()
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Needs_GetAll");
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByCategoryPageId(int categoryPageId)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"Needs_GetByCategoryPageId",categoryPageId);
			return result;
		}
		catch(Exception e) {return null; }
	}

} 
}
